package com.learn.sunday.es.controller;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch.indices.CreateIndexResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping(value = "es/v1/index")
public class ESIndexController {

    @Autowired
    private ElasticsearchClient client;

    public void createIndex() throws IOException {
        CreateIndexResponse indexResponse = client.indices().create(c -> c.index("user"));
    }
}
